package org.maxgroundstation.groundstation.view;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.swing.ImageIcon;

/**
 * A utility class for the video display.
 * @author Scott Davis
 * 
 * Copyright (C) 2010  Scott Davis
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
public final class VideoDisplayUtil {

    // Static data members.
    private static Map<String, ImageIcon> CURRENT_VIDEO_IMAGES;
    private static String CURRENT_VIDEO_SERVICE_NAME;
    private static List<String> VIDEO_SERVICE_NAMES;
    
    // Private default constructor for utility class.
    private VideoDisplayUtil() {};
    
    /**
     * Adds a video service name.
     * @param videoServiceName the video service name.
     */
    public final static void addVideoServiceName(String videoServiceName) {
        if (VIDEO_SERVICE_NAMES == null) {
            VIDEO_SERVICE_NAMES = new ArrayList<String>();
        }
        
        VIDEO_SERVICE_NAMES.add(videoServiceName);
    }
    
    /**
     * Clears the video service names.
     */
    public final static void clearVideoServiceNames() {
        if (VIDEO_SERVICE_NAMES == null) {
            VIDEO_SERVICE_NAMES = new ArrayList<String>();
        }
        
        VIDEO_SERVICE_NAMES.clear();
    }
    
    /**
     * Gets all of the video service names.
     * @return list of video service names.
     */
    public static final List<String> getVideoServicesNames() {
        if (VIDEO_SERVICE_NAMES == null) {
            VIDEO_SERVICE_NAMES = new ArrayList<String>();
        }
        
        return new ArrayList<String>(VIDEO_SERVICE_NAMES);
    }
    
    /**
     * Gets the video service name that is currently displayed.
     * @return video service name.
     */
    public static final String getCurrentVideoServiceName() {
        return CURRENT_VIDEO_SERVICE_NAME;
    }
    
    /**
     * Sets the video service name that is currently displayed.
     * @param videoServiceName the video service name.
     */
    public static final void setCurrentVideoServiceName(String videoServiceName) {
        CURRENT_VIDEO_SERVICE_NAME = videoServiceName;
    }
    
    /**
     * Gets the video image that is currently displayed for a video service.
     * @param videoServiceName the video service name.
     * @return video image.
     */
    public static final ImageIcon getCurrentVideoImage(String videoServiceName) {
        if (CURRENT_VIDEO_IMAGES == null) {
            CURRENT_VIDEO_IMAGES = new HashMap<String, ImageIcon>();
        }
        
        return CURRENT_VIDEO_IMAGES.get(videoServiceName);
    }
    
    /**
     * Sets the video image that is currently displayed for a video service.
     * @param videoServiceName the video service name.
     * @param currentVideoImage the video image.
     */
    public static final void setCurrentVideoImage(String videoServiceName, 
            ImageIcon currentVideoImage) {
        if (CURRENT_VIDEO_IMAGES == null) {
            CURRENT_VIDEO_IMAGES = new HashMap<String, ImageIcon>();
        }
        
        CURRENT_VIDEO_IMAGES.put(videoServiceName, currentVideoImage);
    }
}